package com.fz.action;



import lombok.Data;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by zhuang on 2017-09-14.
 */
@ParentPackage("struts-default")
/*这个加不加都不会对路径造成影响@Namespace("/fff")*/
@Data
public class zhujietest3Action {
    private String fn;
//多个路径是这样配的
@Actions({
        @Action("/different/url"),
        @Action("/another/url")
})
    public String ee() throws IOException {
        //直接在网页输出信息
        HttpServletResponse res = ServletActionContext.getResponse();
        res.setCharacterEncoding("utf-8");
        res.setContentType("text/html;charset=utf-8");
        PrintWriter out = res.getWriter();
        out.print("<h1>Struts2.5.13 入门案例</h1>");//Struts2.5.10 入门案例 波林
        out.flush();
        out.close();
        return null;
    }

//使用配置也可以达到找每个jsp页面的源代码哦
    @Action(value="/ssss",results={@Result(type="plainText",params={"charset", "utf-8","location","/${fn}.jsp"})})
    public String ssss(){
        return "success";
    }
}
